package com.sig.logic;

import com.sig.player.model.Player;
import com.sig.player.event.PlayerEvent;
import com.sig.player.event.PlayerEventListener;

/**
 * @author sig
 * @since 2019/2/21
 */
public abstract class AbstractPlayerEventListener<T extends Player> implements PlayerEventListener {

    @SuppressWarnings("unchecked")
    @Override
    public void onEvent(PlayerEvent event) {
        T player = (T) event.getDispatcher();
        try {
            this.doEvent(player, event);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected abstract void doEvent(T player, PlayerEvent event);
}
